package com.flydog.taskManager.controller;

import com.flydog.taskManager.common.api.CommonResult;
import com.flydog.taskManager.dto.AdminUserParam;
import com.flydog.taskManager.entity.user.AdminUser;
import com.flydog.taskManager.service.AdminUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户相关接口
 *
 * @author caoweidong
 * @version 0.0.0
 * @create 2021/6/15 10:44
 */

@Slf4j
@RestController
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    AdminUserService adminUserService;

    @PostMapping("/register")
    CommonResult<AdminUser> register(@RequestBody AdminUserParam param) {
        return CommonResult.success(adminUserService.register(param));
    }

    @PostMapping("/login")
    CommonResult<String> login(@RequestParam String username, @RequestParam String password) {
        return CommonResult.success(adminUserService.login(username, password));
    }
}
